home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 August: Tool Chest / Dev.CD Aug 94.toast / New System Software Extensions / OpenDoc A6 / OpenDoc Parts Framework / OPF / OS / FWGraphx / Sources / FWInk.cpp < prev    next >
Encoding:
Text File  |  1994-04-21  |  6.4 KB  |  226 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWInk.cpp
  4. //    Release Version:    $ 1.0d1 $
  5. //
  6. //    Creation Date:        3/28/94
  7. //
  8. //    Copyright:    © 1993, 1994 by Apple Computer, Inc., all rights reserved.
  9. //
  10. //========================================================================================
  11.  
  12. #ifndef FWINK_H
  13. #include "FWInk.h"
  14. #endif
  15.  
  16. #ifndef FWGCONST_H
  17. #include "FWGConst.h"
  18. #endif
  19.  
  20. #ifndef FWGC_H
  21. #include "FWGC.h"
  22. #endif
  23.  
  24. // ----- Macintosh Includes -----
  25.  
  26. #if defined(FW_BUILD_MAC) && !defined(__QUICKDRAW__)
  27. #include <Quickdraw.h>
  28. #endif
  29.  
  30. //==============================================================================
  31. //    •• RunTime Info
  32. //==============================================================================
  33.  
  34. #ifdef FW_BUILD_MAC
  35. #pragma segment fwgraphx
  36. #endif
  37.  
  38. //==============================================================================
  39. //    •• class FW_CInk
  40. //==============================================================================
  41.  
  42. //------------------------------------------------------------------------------
  43. // FW_CInk::FW_CInk
  44. //------------------------------------------------------------------------------
  45.  
  46. FW_CInk::FW_CInk() :
  47.     FW_CGraphicObjectPtr()
  48. {
  49. }
  50.  
  51. //------------------------------------------------------------------------------
  52. // FW_CInk::FW_CInk
  53. //------------------------------------------------------------------------------
  54.  
  55. FW_CInk::FW_CInk(const FW_CColor& foreColor, const FW_CColor& backColor, FW_TransferMode tranferMode) :
  56.     FW_CGraphicObjectPtr()
  57. {
  58.     SetRep(new FW_CInkRep(foreColor, backColor, tranferMode));
  59. }
  60.  
  61. //------------------------------------------------------------------------------
  62. // FW_CInk::FW_CInk
  63. //------------------------------------------------------------------------------
  64.  
  65. FW_CInk::FW_CInk(const FW_CInk& other) :
  66.     FW_CGraphicObjectPtr(other)
  67. {
  68. }
  69.  
  70. //------------------------------------------------------------------------------
  71. // FW_CInk::FW_CInk
  72. //------------------------------------------------------------------------------
  73.  
  74. FW_CInk::FW_CInk(FW_CInkRep* rep) :
  75.     FW_CGraphicObjectPtr(rep)
  76. {
  77. }
  78.  
  79. //------------------------------------------------------------------------------
  80. // FW_CInk::operator=
  81. //------------------------------------------------------------------------------
  82.  
  83. FW_CInk& FW_CInk::operator=(const FW_CInk& other)
  84. {
  85.     SetRep(other.GetRep());
  86.     return *this;
  87. }
  88.  
  89. //------------------------------------------------------------------------------
  90. // FW_CInk::operator=
  91. //------------------------------------------------------------------------------
  92.  
  93. FW_CInk& FW_CInk::operator=(FW_CInkRep* other)
  94. {
  95.     SetRep(other);
  96.     return *this;
  97. }
  98.  
  99. //==============================================================================
  100. //    •• class FW_CInkRep
  101. //==============================================================================
  102.  
  103. //------------------------------------------------------------------------------
  104. //    • FW_CInkRep::FW_CInkRep
  105. //------------------------------------------------------------------------------
  106.  
  107. FW_CInkRep::FW_CInkRep():
  108.     fForeColor(FW_kRGBBlack),
  109.     fBackColor(FW_kRGBWhite),
  110.     fTransferMode(FW_kCopy)
  111. {
  112. }
  113.  
  114. //------------------------------------------------------------------------------
  115. //    • FW_CInkRep::FW_CInkRep
  116. //------------------------------------------------------------------------------
  117.  
  118. FW_CInkRep::FW_CInkRep(const FW_CInk& ink)
  119. {
  120.     ink->GetForeColor(&fForeColor);
  121.     ink->GetBackColor(&fBackColor);
  122.     fTransferMode = ink->GetTransferMode();
  123. }
  124.  
  125. //------------------------------------------------------------------------------
  126. //    • FW_CInkRep::FW_CInkRep
  127. //------------------------------------------------------------------------------
  128.  
  129. FW_CInkRep::FW_CInkRep(const FW_CColor& foreColor, const FW_CColor& backColor, FW_TransferMode transferMode):
  130.     fForeColor(foreColor),
  131.     fBackColor(backColor),
  132.     fTransferMode(transferMode)
  133. {
  134. }
  135.  
  136. //----------------------------------------------------------------------------------------
  137. // FW_CInkRep::~FW_CInkRep
  138. //----------------------------------------------------------------------------------------
  139.  
  140. FW_CInkRep::~FW_CInkRep()
  141. {
  142. }
  143.  
  144. //------------------------------------------------------------------------------
  145. //    • FW_CInkRep::SetForeColor
  146. //------------------------------------------------------------------------------
  147.  
  148. void FW_CInkRep::SetForeColor(const FW_CColor& foreColor)
  149. {
  150.     fForeColor = foreColor;
  151.     Changed();
  152. }
  153.  
  154. //------------------------------------------------------------------------------
  155. //    • FW_CInkRep::SetBackColor
  156. //------------------------------------------------------------------------------
  157.  
  158. void FW_CInkRep::SetBackColor(const FW_CColor& backColor)
  159. {
  160.     fBackColor = backColor;
  161.     Changed();
  162. }
  163.  
  164. //------------------------------------------------------------------------------
  165. //    • FW_CInkRep::SetTransferMode
  166. //------------------------------------------------------------------------------
  167.  
  168. void FW_CInkRep::SetTransferMode(FW_TransferMode transferMode)
  169. {
  170.     fTransferMode = transferMode;
  171.     Changed();
  172. }
  173.  
  174. //------------------------------------------------------------------------------
  175. //    • FW_CInkRep::SelectInGC
  176. //------------------------------------------------------------------------------
  177.  
  178. void FW_CInkRep::SelectInGC(FW_CGraphicContext* gc, FW_ShapeCategory shapeCategory)
  179. {
  180. FW_UNUSED(gc);
  181.  
  182. #ifdef FW_BUILD_MAC
  183.     ::RGBForeColor(&fForeColor);
  184.     ::RGBBackColor(&fBackColor);
  185.     
  186.     if (shapeCategory == FW_kGeometricShape)
  187.         ::PenMode(fTransferMode);
  188.     else if (shapeCategory == FW_kTypographicShape)
  189.         ::TextMode(fTransferMode);
  190. #endif
  191.  
  192. }
  193.  
  194. //----------------------------------------------------------------------------------------
  195. //    • FW_CInkRep::Copy
  196. //----------------------------------------------------------------------------------------
  197.  
  198. FW_CInk FW_CInkRep::Copy() const
  199. {
  200.     FW_CInk ink(fForeColor, fBackColor, fTransferMode);
  201.     return ink;
  202. }
  203.  
  204. //----------------------------------------------------------------------------------------
  205. //    • FW_CInkRep::Flatten
  206. //----------------------------------------------------------------------------------------
  207.  
  208. void FW_CInkRep::Flatten(FW_CWritableStream& stream)
  209. {
  210.     fForeColor.Flatten(stream);
  211.     fBackColor.Flatten(stream);
  212.     stream << fTransferMode;
  213. }
  214.  
  215. //----------------------------------------------------------------------------------------
  216. //    • FW_CInkRep::Unflatten
  217. //----------------------------------------------------------------------------------------
  218.  
  219. void FW_CInkRep::Unflatten(FW_CReadableStream& stream)
  220. {
  221.     fForeColor.Unflatten(stream);
  222.     fBackColor.Unflatten(stream);
  223.     stream >> fTransferMode;
  224. }
  225.  
  226.